package hn.cch.spring_boot_security_rest.constant;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;
import java.net.UnknownHostException;


/**
 * 系统信息
 */
public class SystemInfo {


    private static Logger logger = LoggerFactory.getLogger(SystemInfo.class);


    public static final String CHARSET = "UTF-8";


    // 头部信息存储数据字段名称
    public static final String REQUEST_ID = "RequestId";//请求编号
    public static final String START_TIME = "StartTime";//开始时间


    // public static String IP = ipHost();
    public static String HOST_NAME = getHostName();

    /**
     * 获取主机名
     *
     * @return
     */
    public static String getHostName() {

        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            // String hostAddress = inetAddress.getHostAddress();
            // logger.info("HostAddress:{}", hostAddress);
            // return hostAddress;
            String hostName = inetAddress.getHostName();
            logger.info("hostName:{}", hostName);
            return hostName;

        } catch (UnknownHostException e) {

            return null;
        }
    }


}
